<div>
    <h2>Καλάθι Αγορών</h2>
    <?php
    if (empty($result)) {
    ?>
        <p>Δεν υπάρχουν προιόντα στο καλάθι σας.</p>
    <?php
    } else {
    ?>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th>Κατηγορία</th>
                <th>Περιγραφή</th>
                <th>Τιμή</th>
                <th>Ποσότητα</th>
                <th>Τελική τιμή</th>
                <th></th>
            </tr>
        <?php
        $finalprice = 0;
        $i = 0;
        foreach ($result as $record):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
        ?>
            <tr<?php echo $class; ?>>
                <td>
                <?php echo $record['category']; ?>
            </td>
            <td>
                <?php echo $this->Html->link($record['name'], '/products/details/' . $record['id'], array()); ?>
            </td>
            <td>
                <?php echo $record['price']; ?>
            </td>
            <td><?php
                echo $this->Html->link('-', array('action' => 'removeone', $record['id']));
                echo ' ' . $record['quantity'] . ' ';
                echo $this->Html->link('+', array('action' => 'addone', $record['id']));
                ?>
            </td>
            <td><?php
                $fullprice = $record['quantity'] * $record['price'];
                $finalprice = $finalprice + $fullprice;
                echo $fullprice;
                ?>
            </td>
            <td><?php echo $this->Html->link('Διαγραφή', array('action' => 'delete', $record['id']), null, sprintf('Are you sure you want to delete # %s?', $record['name'])); ?></td>
        </tr>
        <?php endforeach; ?>
                <tr>
                    <td colspan="4" style="text-align: right">Σύνολο:</td>
                    <td><?php echo $finalprice ?></td>
                    <td><?php echo $this->Html->link('Διαγραφή όλων', array('action' => 'deleteall', array()), null, sprintf('Are you sure you want to delete all the items')); ?></td>
                </tr>
            </table>
        <div class="actions"><?php echo $this->Html->link('Ολοκλήρωση παραγγελίας', '/orders/checkout/', array()); ?></div>
    <?php } ?>
</div>